<script setup lang="ts">
import { ref } from 'vue'
import { useCounterStore } from "../stores/counterStore";
import { defineProps } from 'vue'

import Son from './Son.vue';
import Daughter from './Daughter.vue';


const counterStore = useCounterStore();
const countObject = ref(counterStore);

const add = () => {
  counterStore.add();
};

const sub = () => {
  counterStore.sub();
};


</script>

<template>
  <div class="father">
    父亲：(家庭总资产为：{{ countObject.count }})
    <button @click="add">赚钱</button>
    <button @click="sub">花钱</button>

    <Son :count="countObject.count" @makeMoney="add" @spendMoney="sub"></Son>
    <Daughter :count="countObject.count" ></Daughter>
  </div>
</template>

<style scoped>
.father {
  margin-top: 20px;
  margin-left: 20px;
  background-color: #ff0000;
  color: #ffffff;
  width: 900px;
  height: 480px;
}
</style>